//
//  BuKeXiangQingBanJiDetailHeaderView.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/26.
//  Copyright © 2019 SanYi. All rights reserved.
//

#import "BuKeXiangQingBanJiDetailHeaderView.h"

@implementation BuKeXiangQingBanJiDetailHeaderView

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self initSubView];
        [self layout];
    }
    return self;
}
- (void)initSubView{
    self.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.nameLabel];
    [self addSubview:self.backView];
    [_backView addSubview:self.genderLabel];
    [_backView addSubview:self.xingMingLabel];
    [_backView addSubview:self.xueHaoLabel];
    [_backView addSubview:self.suoZaiBanJiLabel];
}
- (void)layout{
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.mas_centerX);
        make.top.equalTo(@30);
        make.width.equalTo(@120);
        make.height.equalTo(@15);
    }];
    [_backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@100);
        make.top.equalTo(@50);
        make.right.equalTo(@0).offset(-100);
        make.height.equalTo(@50);
    }];
    
    [_genderLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self->_backView.mas_centerX).offset(20);
        make.centerY.equalTo(self->_backView.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
    }];
    [_suoZaiBanJiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self->_genderLabel.mas_right);
        make.centerY.equalTo(self->_backView.mas_centerY);
        make.width.equalTo(@180);
        make.height.equalTo(@20);
    }];
    [_xingMingLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self->_genderLabel.mas_left);
        make.centerY.equalTo(self->_backView.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
    }];
    [_xueHaoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self->_xingMingLabel.mas_left);
        make.centerY.equalTo(self->_backView.mas_centerY);
        make.width.equalTo(@100);
        make.height.equalTo(@20);
    }];
}
- (UILabel *)nameLabel{
    if (!_nameLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"标题";
        label.textColor = SELECTEDCOLOR;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        _nameLabel = label;
    }
    return _nameLabel;
}

- (UIView *)backView{
    if (!_backView) {
        UIView *view  = [[UIView alloc]init];
        view.backgroundColor = CONTENTBACKCOLOR;
        _backView = view;
    }
    return _backView;
}
- (UILabel *)genderLabel{
    if (!_genderLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"性别";
        label.textColor = TITLECOLOR;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        _genderLabel = label;
    }
    return _genderLabel;
}
- (UILabel *)xueHaoLabel{
    if (!_xueHaoLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"学号";
        label.textColor = TITLECOLOR;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        _xueHaoLabel = label;
    }
    return _xueHaoLabel;
}
- (UILabel *)xingMingLabel{
    if (!_xingMingLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"姓名";
        label.textColor = TITLECOLOR;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        _xingMingLabel = label;
    }
    return _xingMingLabel;
}
- (UILabel *)suoZaiBanJiLabel{
    if (!_suoZaiBanJiLabel) {
        UILabel *label = [[UILabel alloc]init];
        label.text = @"所在班级";
        label.textColor = TITLECOLOR;
        label.textAlignment = 1;
        label.font = [UIFont systemFontOfSize:14];
        _suoZaiBanJiLabel = label;
    }
    return _suoZaiBanJiLabel;
}
- (void)drawRect:(CGRect)rect{
    UIBezierPath *path = [[UIBezierPath alloc]init];
    [path moveToPoint:CGPointMake(self.frame.size.width-100, 49)];
    [path addLineToPoint:CGPointMake(100, 49)];
    [LINCOLOR set];
    [path stroke];
}
@end
